package ControlLayer;

import java.util.ArrayList;

import DBLayer.*;
import ModelLayer.ActivityType;

public class ActivityTypeCtr {
	IFDBActivityType db;

	public ActivityTypeCtr() {
		db = new DBActivityType();
	}

	public int insertActivity(ActivityType at) {
		return db.insertActivity(at);
	}

	public int updateActivity(ActivityType at) {
		return db.updateActivity(at.getID(), at);
	}

	public int deleteActivity(ActivityType at) {
		return db.removeActivity(at.getID());
	}

	public int deleteActivity(long ID) {
		return db.removeActivity(ID);
	}

	public ActivityType getActivity(long ID) {
		return db.getActivity(ID);
	}

	public ArrayList<ActivityType> getActivities() {
		return db.getActivities();
	}

	public boolean activityExists(long ID) {
		ArrayList<ActivityType> list = getActivities();
		boolean exists = false;

		for (ActivityType a : list) {
			if (a.getID() == ID)
				exists = true;
		}

		return exists;
	}

}
